using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using NBear.IoC.Service;
using NBear.IoC.Service.Services.DemoServices;

namespace NBear.Test.UnitTests
{
    public interface ITestService : IServiceInterface
    {
        string Func1(string p1);

        bool Func2(string p1, int p2);
    }

    public class TestService : NBear.IoC.Service.BaseServiceInterfaceImpl, ITestService
    {
        public TestService(NBear.IoC.Service.IServiceContainer container)
            : base(container, typeof(ITestService))
        {
        }

        #region ITestService Members

        public string Func1(string p1)
        {
            return (string)CallService("Func1", typeof(string), p1);
        }

        public bool Func2(string p1, int p2)
        {
            return (bool)CallService("Func2", typeof(bool), p1, p2);
        }

        #endregion
    }

    /// <summary>
    /// Summary description for TestServiceFactory
    /// </summary>
    [TestClass]
    public class TestServiceFactory
    {
        public TestServiceFactory()
        {
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        //[TestMethod]
        public void TestEmitDynamicInterfaceImpl()
        {
            //IServiceContainer container = new NBear.IoC.Service.SimpleServiceContainer(new NBear.IoC.Service.MemoryServiceMQ(), null);
            //container.RegisterComponent("demo", typeof(IMathService), typeof(MathService));
            //IMathService obj = new NBear.IoC.Service.ServiceFactory(container).GetService<IMathService>();
            //
            //Assert.AreEqual(obj.GetResult('/', 10, 2), 5);
        }
    }
}
